<template>
  <div class="myDiv">
    <!-- 复员军人 -->
    <el-card class="box-card secordCard" shadow="never">
      <div slot="header" class="clearfix">
        <span>复员军人信息</span>
        <!-- <el-button style="float: right; padding: 3px 0" type="text">收起</el-button> -->
      </div>
      <div>
        <el-form ref="form" :model="form" :rules="rules" class="formWidth" label-width="190px">
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item label="入伍时间" prop="enlistedDate">
              <el-date-picker clearable size="small"
                v-model="form.enlistedDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择入伍时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
           <el-form-item label="复员时间" prop="demobilizationDate">
              <el-date-picker clearable size="small"
                v-model="form.demobilizationDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择复员时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
           <el-form-item label="原部队代号t" prop="originalUnitCode">
              <el-input v-model="form.originalUnitCode" placeholder="请输入原部队代号t" />
            </el-form-item>
           </el-col>
           <el-col :span="8">
            <el-form-item label="指转业前职务" prop="originalRank">
              <el-input v-model="form.originalRank" placeholder="请输入指转业前职务" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="复员证等其他有效退役证件" prop="demobilizationCertificate">
              <el-input v-model="form.demobilizationCertificate" placeholder="请输入复员证等其他有效退役证件" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="复员证件号码" prop="demobilizationCertificateCode">
              <el-input v-model="form.demobilizationCertificateCode" placeholder="请输入复员证件号码" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="立功受奖情况" prop="honour">
              <el-select v-model="form.honour" placeholder="请选择立功受奖情况">
                <el-option
                  v-for="dict in honourOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="立功受奖证件" prop="honourCertificate">
              <el-input v-model="form.honourCertificate" placeholder="请输入立功受奖证件" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="人员类别" prop="category">
              <el-select v-model="form.category" placeholder="请选择人员类别">
                <el-option
                  v-for="dict in categoryOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="待遇情况" prop="treatmentSituation">
              <el-select v-model="form.treatmentSituation" placeholder="请选择待遇情况">
                <el-option
                  v-for="dict in treatmentSituationOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="孤老情况" prop="isLonely">
              <el-select v-model="form.isLonely" placeholder="请选择孤老情况">
                <el-option
                  v-for="dict in isLonelyOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="供养情况" prop="supportSituation">
              <el-select v-model="form.supportSituation" placeholder="请选择供养情况">
                <el-option
                  v-for="dict in supportSituationOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="供养单位" prop="supportUnit">
              <el-select v-model="form.supportUnit" placeholder="请选择供养单位">
                <el-option
                  v-for="dict in supportUnitOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="安置计划年度" prop="arrangeYear">
              <el-input v-model="form.arrangeYear" placeholder="请输入安置计划年度" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="接收年月" prop="receiveDate">
              <el-input v-model="form.receiveDate" placeholder="请输入接收年月" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
             <el-form-item label="现就业状况" prop="employmentSituation">
              <el-select v-model="form.employmentSituation" placeholder="请选择现就业状况">
                <el-option
                  v-for="dict in employmentSituationOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
       </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "demobilizationCard",
  data(){
    return {
      // 立功受奖情况字典
      honourOptions: [],
      // 人员类别字典
      categoryOptions: [],
      // 待遇情况字典
      treatmentSituationOptions: [],
      // 孤老情况字典
      isLonelyOptions: [],
      // 供养情况字典
      supportSituationOptions: [],
      // 供养单位字典
      supportUnitOptions: [],
      // 现就业状况字典
      employmentSituationOptions: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        enlistedDate: [
          { required: true, message: "入伍时间不能为空", trigger: "blur" }
        ],
      }
    }
  },
  props:{
    soldierId: String,
  },
  mounted(){
    this.form.soldierId = this.soldierId
  },
  created() {
    this.getDicts("honour").then(response => {
      this.honourOptions = response.data;
    });
    this.getDicts("demobilization_soldier_type").then(response => {
      this.categoryOptions = response.data;
    });
    this.getDicts("treatment _situation").then(response => {
      this.treatmentSituationOptions = response.data;
    });
    this.getDicts("yes_or_no").then(response => {
      this.isLonelyOptions = response.data;
    });
    this.getDicts("support_situation").then(response => {
      this.supportSituationOptions = response.data;
    });
    this.getDicts("support_unit").then(response => {
      this.supportUnitOptions = response.data;
    });
    this.getDicts("employment_situation").then(response => {
      this.employmentSituationOptions = response.data;
    });
  },
  methods:{
    validateForm(){
      return new Promise((resolve , reject) => {
        this.$refs.form.validate(valid => {
          if (valid) {
            resolve();
          } else reject();
        });
      })
    }
  },
}
</script>
<style lang="scss" scoped>
.box-card{
  margin-bottom: 16px;
}
::v-deep .secordCard .el-form-item__content {
   height: 36px;
}
</style>